import request from '@/utils/request.js'

/**
 * 获取角色列表
 * @param page
 * @param size
 * @param searchParams
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function getRoleList(page, size, searchParams) {
  return request.get(`/role/list/${page}/${size}`, {
    params: {
      roleName: searchParams?.roleName || '',
      roleKey: searchParams?.roleKey || '',
      status: searchParams?.status || '',
      startTime: searchParams?.searchTime[0] || '',
      endTime: searchParams?.searchTime[1] || ''
    }
  })
}

/**
 * 添加角色信息
 * @param addForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function addRole(addForm) {
  return request.post('/role/add', addForm)
}

/**
 * 编辑角色信息
 * @param addForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function editRole(addForm) {
  return request.put('/role/edit', addForm)
}

/**
 * 删除角色信息
 * @param roleId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function deleteRole(roleId) {
  return request.delete(`/role/remove/${roleId}`)
}
